<?php

class myappAuth extends baseController {

    public $i = 0;

    function actionIndex() {
        echo "Auth: 0";
    }

    function actionTest2() {

        echo ".";
        usleep(10000);
        ob_flush();
        framework::em()->prev();
    }

    function actionTest1() {

        if (framework::$cli) {
            $ip = $_GET['host'];
            exec("ping $ip -n 1", $info);
            foreach ($info as $string) {
                if (strtolower(substr($string, 0, 5)) == 'reply') {
                    echo $string . " Time:" . date("Y-m-d H:i:s") . "\r\n";
                }
                if (strtolower(substr($string, 0, 7)) == 'request') {
                    echo $string . " Time:" . date("Y-m-d H:i:s") . "\r\n";
                }
            }
            sleep(1);
            ob_flush();
            framework::em()->prev();
        }
    }

    function actionError() {
        $this->view->tpl("common/header");
        echo $content = $this->view->contents();
        //$this->view->tpl("Index");
        //return $content = $this->view->contents();
        //framework::em()->prev();
    }

    function actionTest() {
        //var_dump($db->sqlCommand->getResultCount());
        //var_dump($db->sqlCommand->getResultByArray());
        //var_dump($db->sqlCommand->getResultByOneObject());
        //var_dump($db->sqlCommand->getResultByOneArray());
        //$this->connStr = new framework\system\database\dbConnectionString("Provider=mysql;Source=localhost;Username=root;Password=cuijiahai;Database=test;Charset=utf-8");
        //$this->conn = new framework\system\database\dbConnection();
        //$this->conn->Open($this->connStr);
        $content = file_get_contents(DIR_HTDOCS . DS . "test.jpg");
        cong::mm()->send("message.response.content", $content);
        cong::mm()->send("message.response.contentType", ["image/jpg"]);
        //cong::mm()->send("message.response.expires", 3600);
        //cong::mm()->send("message.response.redirect", "http://baidu.com");
    }

}
